/*! \file Primitive.cpp
 *	\brief 
 *
 *	created:	2009/11/17
 *	created:	17:11:2009   15:17
 *	filename: 	o:\main\libs\gd_dx9\Primitive.cpp
 *	file path:	o:\main\libs\gd_dx9
 *	file base:	Primitive
 *	file ext:	cpp
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */
#include "stdafx.h"
#include "Primitive.h"

#include "Device.h"
#include "VertexFormatUtils.h"

namespace tt{
namespace gd_dx9{

Primitive::Primitive( Device* device )
: m_device(device)
, m_vertexFormat()
, m_vertices()
, m_indices()
{
}

void Primitive::onCreate( const gd::VertexFormat& vertexFormat, UInt vertices, UInt indices )
{
	UInt vertexSize = vertexFormat.vertexSize();
	UInt verticesSize = vertices * vertexSize;
 	m_device->d3dDevice()->CreateVertexBuffer(
		verticesSize,
		0  /*Usage*/,
		toD3D9(vertexFormat), 
		D3DPOOL_DEFAULT, 
		m_vertices.getRef(), 
		NULL);
 
	//UInt indicesSize = indices * sizeof(UInt);
 	//m_device->d3dDevice()->CreateIndexBuffer(indicesSize, m_indices.getRef());
}

} //namespace gd_dx9
} //namespace tt
